import java.util.Scanner;

public class a121_質數又來囉_2 {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		Long a, b;
		
		int prime_count;
		
		while(input.hasNext()) {
			a = input.nextLong();
			b = input.nextLong();

			prime_count = 0;
			for(Long i = a; i <= b; i++) {
				if(PrimeDetermine (i))
					prime_count++;
			}
			
			System.out.println(Integer.toString(prime_count));
			
			input.nextLine();
		}
	}
	
	//-----------------------------------------------------------
	
	public static boolean PrimeDetermine(Long n) {
		if(n == 1)
			return false;
		else if(n == 2 || n == 3)
			return true;
		else if(n % 2 == 0)
			return false;
		else {
			Long end = (long)Math.pow (n, 0.5);
			for(Long i = (long)3; i <= end; i += 2) {
				if(n % i == 0)
					return false;
			}
		}
		return true;
	}
	
}